﻿using AutoMapper;
using J.Status.Application.Command.BookingCommand;
using J.StatusModel;
using MediatR;
using StatusService;

namespace J.Status.Application.Handler.BookingHandler
{
    public class StayCreateHandler : IRequestHandler<StayCreateCommand, int>
    {
        private readonly IMapper mapper;
        private readonly IBookingService bookingService;

        public StayCreateHandler(IMapper mapper, IBookingService bookingService)
        {
            this.mapper = mapper;
            this.bookingService = bookingService;
        }
        public async Task<int> Handle(StayCreateCommand request, CancellationToken cancellationToken)
        {
            StayModel model = mapper.Map<StayModel>(request);
            return await bookingService.AddStay(model);
        }
    }
}
